﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UCL.Powersource.Helpers;

namespace UCL.Powersource.Helpers
{
    public class SelectedCollection<T> : IReadOnlyCollection<T>, INotifyCollectionChanged
            where T : class, ILabel
    {

        private SelectableConfiguration<T> _SelectableConfiguration;

        public SelectedCollection(SelectableConfiguration<T> sc)
        {
            _SelectableConfiguration = sc;
        }


        public int Count
        {
            get { return _SelectableConfiguration.Count(a => a.IsSelected); }
        }

        public IEnumerator<T> GetEnumerator()
        {
            return _SelectableConfiguration.GetSelected();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return _SelectableConfiguration.GetSelected();
        }

        public event NotifyCollectionChangedEventHandler CollectionChanged;

        internal void RaiseCollectionChange(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (CollectionChanged != null)
            {
                CollectionChanged(sender, e);
            }
        }

    }
}
